/**
 *充值
 * @returns
 */
'use strict';
const user = uniCloud.importObject('two-plus-one')
const db = uniCloud.database();
const dbcmd = db.command
module.exports = async (obj) => {
	let user_order_success = true;
	let {
		data = {}
	} = obj;
	let {
		order_no,
		out_trade_no,
		total_fee,
		user_id
	} = data; // uni-pay-orders 表内的数据均可获取到
	
	//更改充值订单状态
	let upRes = await db.collection("wolf-pay-order").where({
		order_no
	}).update({
		status:1
	})
	
	//更新用户的 福币余额
	let upUser = await db.collection("uni-id-users").doc(user_id).update({
		gift_money:dbcmd.inc(total_fee)
	})
	
	console.log("rechange+++===>>>>",upRes,upUser);
	return user_order_success;
};